package com.demo;

import com.lee.utils.HiveJdbcUtil;

import java.sql.Connection;
import java.sql.ResultSet;

/**
 * @author Boomlee
 * @description TODO
 * @date 2023/7/18 10:47
 */

public class HiveSqlDemo {
    public static void main(String[] args) throws Exception {

        Connection conn = HiveJdbcUtil.getConnection();

        ResultSet rs = conn.createStatement().executeQuery("desc ods_ptcpb.a_hospital");

        StringBuilder sb = new StringBuilder();
        sb.append("create table ods_ptcpb.a_hospital ( \n");
        while (rs.next()) {
            sb.append("`"+rs.getString("col_name")+"`").append(" ").append(rs.getString("data_type"));
            sb.append(",\n");
        }
        sb.setLength(sb.length() - 2); // 移除最后一个逗号和换行符
        sb.append("\n);");

        System.out.println(sb.toString());
    }

}
